In [1]:
Requirement already satisfied: yfinance in c:\users\asus\anaconda3\lib\site-packages (0.2.37)
Requirement already satisfied: pandas>=1.3.0 in c:\users\asus\anaconda3\lib\site-packages (from yfinance) (2.0.3)
Requirement already satisfied: numpy>=1.16.5 in c:\users\asus\anaconda3\lib\site-packages (from yfinance) (1.24.3)
Requirement already satisfied: requests>=2.31 in c:\users\asus\anaconda3\lib\site-packages (from yfinance) (2.31.0)
Requirement already satisfied: multitasking>=0.0.7 in c:\users\asus\anaconda3\lib\site-packages (from yfinance) (0.0.11)
Requirement already satisfied: lxml>=4.9.1 in c:\users\asus\anaconda3\lib\site-packages (from yfinance) (4.9.2)
Requirement already satisfied: appdirs>=1.4.4 in c:\users\asus\anaconda3\lib\site-packages (from yfinance) (1.4.4)
Requirement already satisfied: pytz>=2022.5 in c:\users\asus\anaconda3\lib\site-packages (from yfinance) (2022.7)
Requirement already satisfied: frozendict>=2.3.4 in c:\users\asus\anaconda3\lib\site-packages (from yfinance) (2.4.0)
Requirement already satisfied: peewee>=3.16.2 in c:\users\asus\anaconda3\lib\site-packages (from yfinance) (3.17.1)
Requirement already satisfied: beautifulsoup4>=4.11.1 in c:\users\asus\anaconda3\lib\site-packages (from yfinance) (4.12.2)
Requirement already satisfied: html5lib>=1.1 in c:\users\asus\anaconda3\lib\site-packages (from yfinance) (1.1)
Requirement already satisfied: soupsieve>1.2 in c:\users\asus\anaconda3\lib\site-packages (from beautifulsoup4>=4.11.1->yfinance) (2.4)
Requirement already satisfied: six>=1.9 in c:\users\asus\anaconda3\lib\site-packages (from html5lib>=1.1->yfinance) (1.16.0)
Requirement already satisfied: webencodings in c:\users\asus\anaconda3\lib\site-packages (from html5lib>=1.1->yfinance) (0.5.1)
Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\asus\anaconda3\lib\site-packages (from pandas>=1.3.0->yfinance) (2.8.2)
Requirement already satisfied: tzdata>=2022.1 in c:\users\asus\anaconda3\lib\site-packages (from pandas>=1.3.0->yfinance) (2023.3)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\asus\anaconda3\lib\site-packages (from requests>=2.31->yfinance) (2.0.4)
Requirement already satisfied: idna<4,>=2.5 in c:\users\asus\anaconda3\lib\site-packages (from requests>=2.31->yfinance) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\asus\anaconda3\lib\site-packages (from requests>=2.31->yfinance) (1.26.16)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\asus\anaconda3\lib\site-packages (from requests>=2.31->yfinance) (2023.7.22)
Note: you may need to restart the kernel to use updated packages.
In [2]:
In [3]:
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
                        Open       High        Low      Close  Adj Close  \
Ticker Date                                                                
AAPL   2019-02-28  43.580002  43.727501  43.230000  43.287498  41.672829   
       2019-03-01  43.570000  43.787498  43.222500  43.742500  42.110859   
       2019-03-04  43.922501  44.437500  43.492500  43.962502  42.322643   
       2019-03-05  43.985001  44.000000  43.634998  43.882500  42.245628   
       2019-03-06  43.667500  43.872501  43.485001  43.630001  42.002556   

                      Volume  
Ticker Date                   
AAPL   2019-02-28  112861600  
       2019-03-01  103544800  
       2019-03-04  109744800  
       2019-03-05   78949600  
       2019-03-06   83241600  
In [4]:
  Ticker       Date       Open       High        Low      Close  Adj Close  \
0   AAPL 2019-02-28  43.580002  43.727501  43.230000  43.287498  41.672829   
1   AAPL 2019-03-01  43.570000  43.787498  43.222500  43.742500  42.110859   
2   AAPL 2019-03-04  43.922501  44.437500  43.492500  43.962502  42.322643   
3   AAPL 2019-03-05  43.985001  44.000000  43.634998  43.882500  42.245628   
4   AAPL 2019-03-06  43.667500  43.872501  43.485001  43.630001  42.002556   

      Volume  
0  112861600  
1  103544800  
2  109744800  
3   78949600  
4   83241600  
In [5]:
Jul 2019Jan 2020Jul 2020Jan 2021Jul 2021Jan 2022Jul 2022Jan 2023Jul 2023Jan 202450100150200250300350400
TickerAAPLMSFTStock Market Performance for the Last 60 MonthsDateClose
In [6]:
2020202120222023202405010015020025030035040020202021202220232024
CompanyAAPLMSFTStock Prices for Apple, MicrosoftDateDateClosing PriceCompany=AAPLCompany=MSFT
In [7]:
Moving Averages for AAPL
            MA10        MA20
0            NaN         NaN
1            NaN         NaN
2            NaN         NaN
3            NaN         NaN
4            NaN         NaN
...          ...         ...
1253  185.297000  187.395999
1254  184.792999  186.889499
1255  184.212999  186.306999
1256  183.443999  185.743999
1257  182.992000  185.289000

[1258 rows x 2 columns]
Moving Averages for MSFT
            MA10        MA20
1258         NaN         NaN
1259         NaN         NaN
1260         NaN         NaN
1261         NaN         NaN
1262         NaN         NaN
...          ...         ...
2511  409.536996  407.437996
2512  409.296997  407.892496
2513  408.919998  408.165996
2514  407.619000  408.346497
2515  406.841000  408.234497

[1258 rows x 2 columns]
In [8]:
Jul 2019Jan 2020Jul 2020Jan 2021Jul 2021Jan 2022Jul 2022Jan 2023Jul 2023Jan 2024406080100120140160180200
variableCloseMA10MA20AAPL Moving AveragesDatevalue
Jul 2019Jan 2020Jul 2020Jan 2021Jul 2021Jan 2022Jul 2022Jan 2023Jul 2023Jan 2024100150200250300350400
variableCloseMA10MA20MSFT Moving AveragesDatevalue
In [ ]:
In [9]:
406080100120140160180200100150200250300350400
Correlation between Apple and MicrosoftAAPLMSFT
In [11]:
100200050150050100150200250300350400
Correlation between Apple and MicrosoftAAPLMSFTCorrelation coefficient: 0.96
In [10]:
R-squared (Training): 0.92
R-squared (Testing): 0.92
Mean Squared Error (Training): 453.56
Mean Squared Error (Testing): 389.32
In [ ]: